<?php

namespace sm_shop_plugin_diy\model;
use sm_shop\model;

class diyModel extends model{

    public static function single( $diy_id ){

        global $_W;

        $sql = 'select * from sh_diy where uniacid=' . $_W['uniacid'] . ' and id=' . $diy_id ;
        return pdo_fetch( $sql );


    }

    public static function edit( $diy_id, $data ){

        $sql = 'update sh_diy set '
            . " title='" . $data['title'] . "',"
            . " diy='" . $data['diy'] . "',"
            . " updated_at='" . $data['updated_at'] . "' "
            . " where id= " . $diy_id;

        return pdo_query( $sql );

    }

    public static function create( $data ){

        $sql = "insert into sh_diy set "
            . " title='" . $data['title'] . "',"
            . " diy='" . $data['diy'] . "',"
            . " uniacid='" . $data['uniacid'] . "',"
            . " updated_at='" . $data['updated_at'] . "',"
            . " created_at='" . $data['created_at'] . "';"
        ;
        return pdo_query( $sql );

    }

    public static function delete( $diy_id ){

        $sql = 'delete from sh_diy '
            . " where id= " . $diy_id;
        return pdo_query( $sql );

    }

}